 <template>
	<view class="repair-wrap">
		<view class="bg-white mb-2 pb-4 pt-4"><h2 style="text-align: center;">{{personnelList.projectName}}</h2></view>
		<view class="p-4 pt-0 bg-white ml-2 mr-2">
			
			<view class="flexClsNowrapSpcBtw  pl-2 pr-2 pt-4 pb-4  border-bottom">
				<view style="color:#999">所属公司：</view>
				<view>{{personnelList.orgName}}</view>
			</view>
			<view class="flexClsNowrapSpcBtw pl-2 pr-2 pt-4 pb-4 border-bottom">
				<view style="color:#999">合同周期：</view>
				<view>{{personnelList.projectJoinTimeStr}}至{{personnelList.projectContractEndTimeStr}}</view>
			</view>
			<view class="flexClsNowrapSpcBtw pl-2 pr-2 pt-4 pb-4 border-bottom">
				<view style="color:#999">服务单位：</view>
				<view>{{personnelList.projectName}}</view>
			</view>
			<view class="flexClsNowrapSpcBtw pl-2 pr-2 pt-4 pb-4 border-bottom">
				<view style="color:#999">项目业态：</view>
				<view>{{personnelList.projectCommunityType==0?"不限":personnelList.projectCommunityType==1?"住宅":personnelList.projectCommunityType==2?"别墅":
						personnelList.projectCommunityType==3?"写字楼":personnelList.projectCommunityType==4?"商住两用":personnelList.projectCommunityType==5?"多业态型":
						personnelList.projectCommunityType==6?"公寓":personnelList.projectCommunityType==7?"商场":personnelList.projectCommunityType==8?"学校":
						personnelList.projectCommunityType==9?"厂房":personnelList.projectCommunityType==10?"市场":"其它"}}
				</view>
			</view>
			<view class="flexClsNowrapSpcBtw pl-2 pr-2 pt-4 pb-4 border-bottom">
				<view style="color:#999">服务等级：</view>
				<view style="margin-top: -4px;display: flex;">
					<text style="color: gold;font-size: 18px;margin-top:-1px;">★</text>
					<view style="color: gold;margin-left: 8px;margin-top: 5px;">
					{{personnelList.projectScore}}
					</view>
					<view style="margin-left: 8px;margin-top: 5px;">分</view>
				</view>
			</view>
			<view class="flexClsNowrapSpcBtw pl-2 pr-2 pt-4 pb-4 border-bottom">
				<view style="color:#999">项目地址：</view>
				<view>{{personnelList.projectLocation}}</view>
			</view>
		<!-- 	<view class="flexClsNowrapSpcBtw pl-2 pr-2 pt-4 pb-4 border-bottom">
				<view style="color:#999">物业费单价：</view>
				<view>{{personnelList.projectName}}</view>
			</view> -->
		</view>
		<view>
			<button style="color:#ffffff" class="button_on" type="default" @click="clickBtn()">点击预览合同</button>
		</view>

	</view>
</template>

<script>
	// import lFile from '@/components/l-file/l-file.vue'
	export default {
		// comments: {
		// 	lFile
		// },
		data() {
			return {
				repairList:[],
				pageIndex:1,
				loading: false,
				// type: 1,
				nextPage:false,
				listData:[],
				limit: 10, //每页数据多少
				curPage: 1 ,//当前页
				personnelList:{},
				pro_id:uni.getStorageSync(
									'projectItem').proId,
			}
		},
		onLoad(options) {
			console.log(options)
			// this.pro_id = options.project_id
			this.getList()
		
		},
		onShow() {
			let _this = this
			if (uni.getStorageSync('phone')) {
				if (uni.getStorageSync('loginFlag')) {
					if (!uni.getStorageSync('hourseList')) {
						uni.showModal({
							title: '请先进行业主认证',
							showCancel: false,
							confirmText: '确认',
							confirmColor: '#F9A832',
							success: function(res) {
								if (res.confirm) {
									_this.$Router.push({
										path: '/my/address/address'
									})
								}
							}
						});
						this.$openInvite()
					} else {
						_this.showFlag = true
						_this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
						_this.name = _this.homelist.proName;
						_this.address = _this.homelist.buildDistrictCode + '-' + _this.homelist.buildTowerCode + '-' + _this.homelist.roomUnitNumber +'-'+ _this.homelist.roomCode
						// _this.getList()
					}
				} else {
					uni.showModal({
						title: '请先实名认证',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								_this.$Router.push({
									path: '/pages/realName/realName'
								})
							}
						}
					});
				}
			} else {
				uni.showModal({
					title: '请先登录',
					showCancel: false,
					confirmText: '确认',
					confirmColor: '#F9A832',
					success: function(res) {
						if (res.confirm) {
							console.log('a')
							_this.$Router.pushTab({
								path: '/pages/user/user'
							})
						}
					}
				});
			}
		},
		methods: {
			natov(url){
				uni.navigateTo({
					url:url
				})
			},
			// 获取列表
			getList() {
				this.$request.api.getpersonnellist({
					project_id:this.pro_id,
					types:"jhyutkhjhg"
				}).then(res => {
					this.personnelList = res.data.data
					console.log(this.personnelList)
					if(this.personnelList.projectContract != null){
						// this.clickBtn()
					}else{
						uni.showModal({
							title: '温馨提示',
							content: '此社区没有物业合同',
							success: function (res) {
								if (res.confirm) {
									console.log('用户点击确定');
									uni.switchTab({//跳转页面
										url:"/pages/index/newIndex"
									})
								} else if (res.cancel) {
									console.log('用户点击取消');
									uni.switchTab({//跳转页面
										url:"/pages/index/newIndex"
									})
								}
							}
						});
					}
				})
			},
			clickBtn(){
				uni.downloadFile({
				  url: this.personnelList.projectContract,
				  success: function (res) {
					var filePath = res.tempFilePath;
					uni.openDocument({
					  filePath: filePath,
					  showMenu: true,
					  success: function (res) {
						console.log('打开文档成功');
					  },
					  fail() {
					  	console.log('打开文档失败');
					  }
					});
				  }
				});
			}
			
		}
	}
</script>

<style lang="scss">
	page{
		background: #f4f4f4;
	}
	.repair-wrap {
		width: 100%;
		// min-height: 100vh;
		height: auto;
		background: #f4f4f4;
		overflow: hidden;

		.repair-box {
			background: #fff;

			.repair-titel {
				height: 44rpx;
				line-height: 44rpx;

				.repair-titel-l {
					float: left;
				}

				.repair-titel-r {
					float: right;
					color: #999;
				}
			}

			.repair-6 {
				color: #666;
			}
		}
	}
	.repair-titel i{
		width: 6px;
		height: 13px;
		background: linear-gradient(180deg, #76D904 0%,#417505 100%);
		border-radius: 4px;
		display: inline-block;
		vertical-align: middle;
		margin-top: 4px;
	}
	.button_on{
		background: linear-gradient(180deg, #76D904 0%, #417505 100%);
		width: 80%;
		margin-top: 30px;
		border-radius: 12px;
	}
</style>
